package com.base.vistter.iframe.security.handler;

import com.base.vistter.iframe.menu.ErrorLoginEnum;
import com.base.vistter.iframe.utils.IoUtils;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import java.io.IOException;

/**
 * 自定义用户未登录的处理（未携带token）
 */
public class IframeAuthenticationEntryPoint implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
        IoUtils.errorWrite(ErrorLoginEnum.USER_UNLOGIN, response);
    }

}
